
// 方法一 用于数据解析  字面量  json
var student = {
    id: 00001,
    name: "张三",
    scores: [
        { subject: "html", score: 90 },
        { subject: "js", score: 90 }
    ]
}
console.log(student.id);
// 方法二  
function student(id,name){
        this.id=id;
        this.name=name;
        this.score=score=[
            { subject: "html", score: 90 },
            { subject: "js", score: 90 }
        ];
}
//扩展 prototype扩充
student.prototype.sex="男";
student.prototype.eat=function(food){
  console.log("吃"+food);
}
var stu=ew student(1000,"張三");
stu.eat("米饭");

// 方法三 创建object对象
//object
var stu2=new Object();
stu2.id=1000;
stu2.name="張三";
stu2.score=[
    { subject: "html", score: 90 },
    { subject: "js", score: 90 }
]
//链式编程
function student(id,name){
    this.id=id;
    this.name=name;
    this.eat=function(food){
        console.log("吃"+food);
       return this;
    },
    this.sleep=function( ){
        console.log("睡");
        return this;
    }
}
var stu=new student(10001,"张三"); 
stu.eat("").sleep().eat("").sleep().eat("").sleep().eat("").sleep().eat("").sleep();
//stu.sleep();
